<?
if(! defined('BASEPATH') ){ exit('Unable to view file.'); }
$mesaj = '<div class="message info">Connect to Admin Panel</div>';

if(isset($_POST['logare'])) {
	$name = $db->EscapeString($_POST['login']);
	$pass = $db->EscapeString($_POST['pass']);

	$sql = $db->Query("SELECT id FROM `admins` WHERE `login`='".$name."' AND `pass`=MD5('".$pass."')");
	$num = $db->GetNumRows($sql);
	if($num > 0) {
		$db->Query("UPDATE `admins` SET `online`=NOW() WHERE `login`='".$name."'");
		$_SESSION['EX_admin'] = $name;
		redirect('index.php');
    }else{
		$mesaj = '<div class="message error">Wrong Username or Password</div>';
   }
  }
?>
<body class="login">
    <div class="login-box widget">
      <header><h2>Admin Login</h2></header>
    	<section>
		<?=$mesaj?>
    		<form id="form" method="post">
			<p>
				<input type="text" id="login"  class="full" value="" name="login" required="required" placeholder="Username" />
			</p>
			<p>
				<input type="password" id="password" class="full" value="" name="pass" required="required" placeholder="Password" />

			</p>
			<p class="clearfix">
				<button class="button button-gray fr" type="submit" name="logare">Login</button>
			</p>
		</form>
		<ul><li><a href="#">Forgot password?</a></li></ul>
    	</section>
    </div>
</body>